package com.yyh.fanxing;

import java.util.Deque;
import java.util.LinkedList;

/*栈：LIFO |后进先出
* 明确：在Java提供了一个接口queue，该接口继承了Queue接口，该接口定义了队列的操作方法
* 栈的操作方法：
*   push(E e):添加元素
*   pop():获取栈顶元素，并删除栈顶元素
*   peek():获取栈顶元素，不删除栈顶元素
*   isEmpty():判断栈是否为空
*   size():获取栈中元素个数
*   clear():清空栈
* */
public class Demo3 {
    public static void main(String[] args) {
        Deque<Integer> deque = new LinkedList<>();
        deque.push(1);
        deque.push(2);
        deque.push(3);
        deque.push(4);
        deque.push(5);
        System.out.println("deque = "+ deque);
        Integer pop = deque.pop();
        System.out.println("pop = " + pop);
        System.out.println("deque = " + deque);
        Integer peek = deque.peek();
        System.out.println("peek = " + peek);
        System.out.println("deque = " + deque);
        int size = deque.size();
        System.out.println("size = " + size);

    }
}
